'定义变量
Dim ado As Object
Dim strPath As String
Dim str_ado As String
Set ado = CreateObject("adodb.connection")
strPath = ThisWorkbook.FullName  '数据源工作簿的完整路径

'判断Excel版本号，以使用不同的连接字符串
If Application.Version < 12 Then
    str_ado = "Provider=Microsoft.jet.OLEDB.4.0;Extended Properties=Excel 8.0;Data Source=" & strPath
Else
    str_ado = "Provider=Microsoft.ACE.OLEDB.12.0;Extended Properties=Excel 12.0;Data Source=" & strPath
End If
'建立链接
ado.Open str_ado
'处理数据


'关闭链接
ado.Close
'释放内存
Set ado = Nothing